param ([string] $filename, [string] $outputfilename,[switch] $debug, [switch] $help) 



function usage() {
	Write-Host "Diff2HTML.ps1 -filename <reference filename> -outputfilename <Absolutefilename> [-debug] [-help]" 
}

function fail( [string] $message) {

	Write-Host "the program encounter an error : " 
	Write-Host "$message"
	usage
	exit 1 ;
}

Write-Host "	<Diff2HTML.ps1>  Copyright (C) 2012  Laurent.Tardif (laurent.tardif@persistentsas.com)"
Write-Host ""
Write-Host "    This program comes with ABSOLUTELY NO WARRANTY; for details see the copyrith.txt file."
Write-Host "    This is free software, and you are welcome to redistribute it"
Write-Host "    under certain conditions; Read the copyrith.txt file for details."


if([String]::IsNullOrEmpty($filename))
{
		fail "The filename element was not provided as parameter"
} 
if([String]::IsNullOrEmpty($outputfilename))
{
		fail "The outputfilename element was not provided as parameter"
} 


if ($help) {
	usage
	exit 0
}

# -----------------------------------------------------------------------
#
#   BEGIN OF ANALYSE
#
# -----------------------------------------------------------------------
$script:xslt = new-object system.xml.xsl.xslcompiledtransform
 
$xslFilePath= resolve-path ".\xsl\transformDiff.xsl"
## load xslt file
$xslt.load( $xslFilePath)
    
$originalXmlFilePath=resolve-path "$filename"
## transform
$xslt.Transform( $originalXmlFilePath, $outputfilename )
Write-Host "Transformation is finished " 
